package com.murray.assignment.controller;

import com.murray.assignment.pojo.Category;
import com.murray.assignment.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * @author Murray
 * @Date 2021/6/6
 * @Time 19:59
 */
@Controller
public class IndexController {

    @Autowired
    private CategoryService categoryService;

    @RequestMapping("/index")
    public ModelAndView jumpToIndex() {
        List<Category> categoryList = categoryService.findAll();
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("index");
        modelAndView.addObject("myCategoryList",categoryList);
        return modelAndView;
    }

}
